package com.langshixiaobai.admin.common.utils;


import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.redisson.client.codec.Codec;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RBloomFilterConfiguration {

    /**
     * 防止用户注册查询数据库的布隆过滤器
     */
    @Bean
    public RBloomFilter<String> userRegisterCachePenetrationBloomFilter(RedissonClient redissonClient){

        RBloomFilter<String> bloomFilter = redissonClient.getBloomFilter("userRegisterCachePenetrationBloomFilter");
        bloomFilter.tryInit(10000, 0.1);
        return bloomFilter;
    }
}
